package com.zwh.rabbitmq.module.project.mq;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;

import javax.validation.constraints.NotNull;

import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

import com.zwh.rabbitmq.config.ReliableRabbitTemplate;
import com.zwh.rabbitmq.module.project.ProjectMqConstants;
import com.zwh.rabbitmq.module.project.dto.ProjectInfoDto;


/**
 * 项目消息推送到rabbitmq封装类
 * 
 * @author zwh
 * @date 2021/12/8 9:42
 **/
@Component
public class ProjectRabbitMqSender {
    /**
     * 自定义发送消息队列模板，object对象使用json序列化
     */
    @Autowired
    @Qualifier("rabbitJsonTemplate")
    private ReliableRabbitTemplate rabbitTemplate;


    /**
     * rabbitmq发送项目新增消息
     *
     */
    @Async("businessTaskExecutor")
    public void sendProjectAdd() {
        ProjectInfoDto projectInfoDto = new ProjectInfoDto();
        projectInfoDto.setId(String.valueOf(System.currentTimeMillis()));
        projectInfoDto.setProjectName("测试项目");
        rabbitTemplate.sendMsgAndSaveRecord(ProjectMqConstants.PROJECT_DELETE_QUEUE, projectInfoDto.getId(),
                ProjectMqConstants.CONTRACT_OR_PROJECT_EXCHANGE, ProjectMqConstants.PROJECT_DELETE_QUEUE,
                projectInfoDto);
    }


}
